package com.jinzhi.jzweb.controller.moduleConfig;

import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.domain.StuSignUpComDO;
import com.jinzhi.jzweb.pojo.ModuleConfig.SignGrade;
import com.jinzhi.jzweb.service.StuSignUpComService;
import com.jinzhi.jzweb.service.moduleConfig.SignGradeService;
import io.swagger.annotations.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/*
 *  @author : JingChangTian
 *  @date   : 2023/11/30 14:46
 *  @description :
 *
 */
@Controller
@RequestMapping("/signgrade")
@Api(value = "实操成绩管理",tags = "实操成绩管理")
public class SignGradeController {

    private final SignGradeService signGradeService;

    private final StuSignUpComService stuSignUpComService;

    public SignGradeController(SignGradeService signGradeService, StuSignUpComService stuSignUpComService) {
        this.signGradeService = signGradeService;
        this.stuSignUpComService = stuSignUpComService;
    }


    @ApiOperation(value = "实操录分列表页面入口", notes = "实操录入页面入口")
    @ApiImplicitParams({
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),@ApiResponse(code = 500, message = "服务器内部异常")})
    @GetMapping("/record")
    String getList() {
        return "jzweb/record/recordPoints";
    }


    @ApiOperation(value = "实操录入页面入口", notes = "实操录入页面入口")
    @ApiImplicitParams({
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),@ApiResponse(code = 500, message = "服务器内部异常")})
    @GetMapping("/add")
    String add() {
        return "jzweb/record/add";
    }


    @ApiOperation(value = "实操改分页面入口", notes = "实操改分页面入口")
    @ApiImplicitParams({
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),@ApiResponse(code = 500, message = "服务器内部异常")})
    @GetMapping("/edit")
    String edit() {
        return "jzweb/record/edit";
    }


    @ApiOperation(value = "新增或者修改用于录分", notes = "新增或者修改用于录分")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "List<SignGrade>", value = "signGrades", required = true, dataType = "List<SignGrade>"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST)
    public Result<Object> insertOrUpdate(@RequestBody List<SignGrade> signGrades){
        return signGradeService.insertOrUpdateBatchs(signGrades);
    }


    @ApiOperation(value = "分数统计列表", notes = "分数统计列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "SignGrade", value = "SignGrade", required = true, dataType = "SignGrade"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @RequestMapping(value = "/getSignGrades", method = RequestMethod.POST)
    public Result<Object> getSignGrades(@RequestBody SignGrade signGrade){
        return signGradeService.getSignGrades(signGrade);
    }


    @ApiOperation(value = "分数录入查询列表", notes = "分数录入查询列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "SignGrade", value = "SignGrade", required = true, dataType = "SignGrade"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @RequestMapping(value = "/getStuSignGrades", method = RequestMethod.POST)
    public Result<Object> getStuSignGrades(@RequestBody SignGrade signGrades){
        return signGradeService.getStuSignGrades(signGrades);
    }


    @ApiOperation(value = "b赛场导出", notes = "b赛场导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cbatchId", value = "cbatchId", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "competition", value = "competition", required = true, dataType = "String"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @RequestMapping(value = "/stuSignGradederive", method = RequestMethod.GET)
    public Result<Object> stuSignGradederive(HttpServletResponse response,Long cbatchId,String competition) throws Exception{
        return signGradeService.stuSignGradederive(response,cbatchId,competition);
    }


    @ApiOperation(value = "录分导出", notes = "录分导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cbatchId", value = "cbatchId", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "competition", value = "competition", required = true, dataType = "String"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @RequestMapping(value = "/recordderive", method = RequestMethod.GET)
    public Result<Object> recordderive(HttpServletResponse response,Long cbatchId,String competition) throws Exception{
        return signGradeService.recordderive(response,cbatchId,competition);
    }


    @ApiOperation(value = "备注修改", notes = "备注修改")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "StuSignUpComDO", value = "stuSignUpComDO", required = true, dataType = "StuSignUpComDO"),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @RequestMapping(value = "/updateRemark", method = RequestMethod.POST)
    public Result<Object> updateRemark(@RequestBody StuSignUpComDO stuSignUpComDO){
        return stuSignUpComService.updateById(stuSignUpComDO) ? Result.ok() : Result.fail();
    }
}
